package cn.edu.qvtu.controller;

import cn.edu.qvtu.util.ApiData;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

//添加班费信息API接口
@WebServlet("/api/log/add.do")
public class LogAddController extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //处理中文乱码
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("application/json;charset=UTF-8");
        //获得输出对象
        PrintWriter out = resp.getWriter();
        //获取请求参数
        String title = req.getParameter("title");
        String date=req.getParameter("date");
        String count=req.getParameter("content");
        String money=req.getParameter("money");
        //调用业务逻辑层的代码，进行添加操作
        LogsService logsService = new LogsServiceIpml();
        ApiData result = logsService.moneyadd(title,date,count,money);
        //输出结果
        out.println(result);
    }
}
